package com.leonwoodstudio.eventdetectionclient;

import android.content.Context;
import android.util.Log;
import android.util.LruCache;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.leonwoodstudio.eventdetectionclient.eventmessage.ParsedEventMessageToSave;

import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by win7 on 2017/4/7.
 */
public class EventHistoryListViewAdapter extends BaseAdapter {
    public List<ParsedEventMessageToSave> event_history_list;
    Context context;

    public EventHistoryListViewAdapter(Context context) {
        this.context = context;
        event_history_list = new ArrayList<>();
    }

    @Override
    public int getCount() {
        return event_history_list.size();
    }

    @Override
    public Object getItem(int position) {
        return event_history_list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        EventHistoryListItem item;
        if (convertView == null) {
            item = new EventHistoryListItem(context);
        } else {
            item = (EventHistoryListItem) convertView;
        }
        item.updateView(event_history_list.get(position));
        return item;
    }
}
